package com.example.memoapp.activities;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Switch;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import com.example.memoapp.R;

public class SettingsActivity extends AppCompatActivity {

    private Switch switchDarkMode;
    private Switch switchAutoSave;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);

        switchDarkMode = findViewById(R.id.switch_dark_mode);
        switchAutoSave = findViewById(R.id.switch_auto_save);

        // 加载用户偏好设置
        SharedPreferences prefs = getSharedPreferences("app_settings", MODE_PRIVATE);
        boolean isDarkMode = prefs.getBoolean("dark_mode", false);
        boolean isAutoSave = prefs.getBoolean("auto_save", false);

        // 设置开关状态
        switchDarkMode.setChecked(isDarkMode);
        switchAutoSave.setChecked(isAutoSave);


        // 监听自动保存切换
        switchAutoSave.setOnCheckedChangeListener((buttonView, isChecked) -> {
            prefs.edit().putBoolean("auto_save", isChecked).apply();
        });
    }
}